package lcr;

public class Test0008 {
    public static void main(String[] args) {
        new Solution0008_1().minSubArrayLen(7,new int[]{2,3,1,2,4,3});
    }
}

class Solution0008_1 {
    public int minSubArrayLen(int target, int[] nums) {
        int len = nums.length, l=0,r=0,sum=0,ans=Integer.MAX_VALUE;
        while (r<len){
            sum+=nums[r];
            while (sum>=target){
                ans=Math.min(ans,r-l+1);
                sum-=nums[l++];

            }

            r++;
        }

        return ans==Integer.MAX_VALUE?0:ans;
    }
}
